首页>代码>springMVC+Mybatis+Spring+Easyui+zTree+ueditor+highchart企业IT信息管理系统>/IT_M - 副本/src/com/gree/ssm/controller/BasedataController.java
package com.gree.ssm.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.gree.ssm.po.BaseDataCustom;
import com.gree.ssm.service.BaseDataService;
/**
 * 下拉框、复选框、radio等基础数据
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/basedata")
public class BasedataController {
	@Autowired
	private BaseDataService basedataService;

	/**
	 * 根据名称加载基础数据
	 * 
	 * @param request
	 * @param response
	 * @param dbName
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/loadByName")
	public @ResponseBody
	List<BaseDataCustom> loadByName(HttpServletRequest request,
			HttpServletResponse response, String dataName) throws Exception {
		List<BaseDataCustom> list = basedataService
				.findBasedataListBydbName(dataName);
		return list;
	}

	@RequestMapping("/opList")
	public String opList(Model model, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// 页面转发
		return "basedata";
	}

	/**
	 * 管理基础数据
	 * 
	 * @param request
	 * @param response
	 * @param dbName
	 * @param page
	 * @param rows
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/queryBasedata")
	public @ResponseBody
	Map<String, Object> queryBasedata(HttpServletRequest request,
			HttpServletResponse response, String dbName, Integer page,
			Integer rows) throws Exception {
		Map<String, Object> re = new HashMap<String, Object>();
		PageInfo<BaseDataCustom> pageInfo = basedataService
				.findBasedataListBydbNamePage(dbName, page, rows);
		re.put("total", pageInfo.getTotal());
		re.put("rows", pageInfo.getList());

		return re;
	}

	/**
	 * 修改
	 * 
	 * @param request
	 * @param response
	 * @param BaseDataCustom
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/updateBasedata")
	public @ResponseBody
	Map<String, Object> updateBasedata(HttpServletRequest request,
			HttpServletResponse response, BaseDataCustom baseDataCustom)
			throws Exception {
		Map<String, Object> re = new HashMap<String, Object>();
		boolean result = basedataService.update(baseDataCustom);
		if (result) {
			re.put("success", true);
			re.put("msg", "修改成功");
		} else {
			re.put("success", false);
			re.put("msg", "修改失败");
		}
		return re;
	}

	/**
	 * 添加
	 * 
	 * @param request
	 * @param response
	 * @param BaseDataCustom
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/addBaseData")
	public @ResponseBody
	Map<String, Object> addBaseData(HttpServletRequest request,
			HttpServletResponse response, BaseDataCustom baseDataCustom)
			throws Exception {
		Map<String, Object> re = new HashMap<String, Object>();
		boolean result = basedataService.add(baseDataCustom);
		if (result) {
			re.put("success", true);
			re.put("msg", "添加成功");
		} else {
			re.put("success", false);
			re.put("msg", "添加失败");
		}
		return re;
	}

	/**
	 * 删除
	 * 
	 * @return
	 */
	@RequestMapping("/delete")
	public @ResponseBody
	Map<Object, Object> delete(Integer[] ids) {
		Map<Object, Object> resMap = new HashMap<Object, Object>();
		boolean result = basedataService.deleteByIds(ids);
		if (result) {
			resMap.put("success", true);
			resMap.put("msg", "删除成功!");
		} else {
			resMap.put("success", false);
			resMap.put("msg", "删除失败!");
		}
		return resMap;
	}
}
最近下载更多
zhaoyangwfd  LV17 2022年1月20日
wanglinddad  LV55 2022年1月19日
543666826  LV33 2021年11月18日
2231788897  LV6 2021年10月20日
lewis365  LV2 2021年8月22日
ericxu1116  LV24 2021年6月7日
幸运疯子  LV13 2021年5月16日
小屁孩  LV7 2021年4月11日
skipple3  LV39 2020年11月26日
ddqddqddq  LV14 2020年9月5日
最近浏览更多
李俊雄  LV3 5月8日
educationAAA  LV6 5月2日
wahaha9zz 4月25日
暂无贡献等级
xiaozhi丶  LV14 4月10日
爱丽淇  LV5 3月13日
pangzhihui  LV13 3月1日
qq1633  LV6 2月19日
heshao  LV2 2月7日
Gin19960217  LV4 1月12日
zhangjilu  LV18 1月7日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友